prepare-root: Only bind mount /home, /tmp, /root if they are directories
authorColin Walters <walters@verbum.org>
Sun, 23 Jun 2013 21:56:14 +0000 (17:56 -0400)
committerColin Walters <walters@verbum.org>
Sun, 23 Jun 2013 21:56:14 +0000 (17:56 -0400)
What we expect for new systems is for these to be symbolic links:
/home -> /sysroot/home
etc.

src/switchroot/ostree-prepare-root.c

index e16d79e5ef877409c9dc60518b851a4e96375cc5..cfd7481e71bcea58f485c9ec46f8cd9a89a2cbe4 100644 (file)
@@ -180,10 +180,16 @@ main(int argc, char *argv[])
     {
       snprintf (srcpath, sizeof(srcpath), "%s%s", root_mountpoint, toproot_bind_mounts[i]);
       snprintf (destpath, sizeof(destpath), "%s%s", deploy_path, toproot_bind_mounts[i]);
-      if (mount (srcpath, destpath, NULL, MS_BIND & ~MS_RDONLY, NULL) < 0)
+      /* Only do these bind mounts if the target exists and is a real directory,
+       * not a symbolic link.
+       */
+      if (lstat (destpath, &stbuf) == 0 && S_ISDIR(stbuf.st_mode))
        {
-         perrorv ("failed to bind mount (class:toproot) %s to %s", toproot_bind_mounts[i], destpath);
-         exit (1);
+         if (mount (srcpath, destpath, NULL, MS_BIND & ~MS_RDONLY, NULL) < 0)
+           {
+             perrorv ("failed to bind mount (class:toproot) %s to %s", toproot_bind_mounts[i], destpath);
+             exit (1);
+           }
        }
     }